home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / fansi.zip / RAWMODE.MAC < prev    next >
Text File  |  1986-08-29  |  3KB  |  107 lines

  1. ;
  2. ;    This is file: RAWMODE.MAC
  3. ;
  4. ;    Written by Mark Hersey
  5. ;    Hersey Micro Consulting, Inc.
  6. ;
  7. ;    This program is public domain.  No copyrights reserved.
  8. ;
  9. ;    The purpose of these subroutines is to allow your program
  10. ;    to use raw console output, which is faster than the
  11. ;    normal (cooked or ASCII) mode.  When the console is in cooked
  12. ;    mode, MS-DOS checks for console input (specifically looking
  13. ;    for Ctrl-C == Ctrl-Break) with every character 
  14. ;    that is written to the screen.  In raw mode, it will not.
  15. ;
  16. ;    You may need to change the procedure names to match
  17. ;    the requirements of your compiler.
  18. ;    You may need to change the segment and group names to match
  19. ;    those used by your compiler.
  20. ;
  21.     .xlist
  22.     include    compiler.mlb
  23.     if1
  24.         include    macros.mlb
  25.     endif
  26.     .list
  27.  
  28.     xinit                    ;Initialize structured macros.
  29.  
  30. dgroup    group    _data
  31.  
  32. _data    segment    byte public 'data'
  33.         assume    nothing
  34.  
  35. saved_mode    db    ?
  36.  
  37.     assume    nothing
  38. _data    ends
  39.  
  40.     if    bigcode
  41. rawmode_text    segment    byte public 'code'
  42.         assume    cs:rawmode_text
  43.     else    ;not bigcode
  44. _text    segment byte public 'code'
  45.     assume    cs:_text
  46.     endif    ;bigcode
  47.     
  48.     assume    ds:dgroup
  49. ;
  50. ;    _raw_mode - Save old mode and put console device into raw mode.
  51. ;
  52. ;    Inputs:
  53. ;        None    
  54. ;    Outputs:
  55. ;        [saved_mode] has old mode in it.
  56. ;        Console is in raw mode.
  57. ;    Comments:
  58. ;        Call once at the start of your program.
  59. procdcl    _raw_mode
  60.     
  61.     mov    ah,044h                ;I/O-Control call for devices.
  62.     mov    al,000h                ;Get device information.
  63.     mov    bx,001h                ;File handle for CON: output.
  64.     int    021h                ;Make MS-DOS call.
  65.     mov    [saved_mode],dl            ;Save old mode.
  66.     mov    ah,044h                ;I/O-Control call for devices.
  67.     mov    al,001h                ;Set device information.
  68.     mov    bx,001h                ;File handle for CON: output.
  69.     xor    dh,dh                ;Must be zero.
  70.     or    dl,020h                ;Set raw mode bit, leave others same.
  71.     int    021h                ;Make MS-DOS call.
  72.     ret
  73.     
  74. _raw_mode    endp
  75. ;
  76. ;    _old_mode - Save old mode and put console device into raw mode.
  77. ;
  78. ;    Inputs:
  79. ;        [saved_mode] has old mode in it.
  80. ;    Outputs:
  81. ;        Console is set to [saved_mode].
  82. ;    Comments:
  83. ;        Call once at the end of your program.
  84. ;
  85. procdcl    _old_mode
  86.     
  87.     mov    ah,044h                ;I/O-Control call for devices.
  88.     mov    al,001h                ;Set device information.
  89.     mov    bx,001h                ;File handle for CON: output.
  90.     xor    dh,dh                ;Must be zero.
  91.     mov    dl,[saved_mode]            ;Get old mode.
  92.     int    021h                ;Make MS-DOS call.
  93.     ret
  94.  
  95. _old_mode    endp
  96.  
  97.         assume    nothing
  98.  
  99.     if    bigcode
  100. rawmode_text    ends
  101.     else    ;not bigcode
  102. _text    ends    
  103.     endif    ;bigcode
  104.  
  105.     end
  106.